﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MVC.Web.UI
{
    public abstract class WebControlCollection<T> : IControlCollection<T>
    {
        private List<T> _list = null;

        public WebControlCollection()
        {
            _list = new List<T>();
        }

        public int IndexOf(T item)
        {
            return this._list.IndexOf(item);
        }

        public void Insert(int index, T item)
        {
            this._list.Insert(index, item);
        }

        public void RemoveAt(int index)
        {
            this._list.RemoveAt(index);
        }

        public T this[int index]
        {
            get
            {
                return this._list[index];
            }
            set
            {
                this._list[index] = value;
            }
        }

        public void Add(T item)
        {
            this._list.Add(item);
        }

        public void Clear()
        {
            this._list.Clear();
        }

        public bool Contains(T item)
        {
            return this._list.Contains(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            this._list.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return this._list.Count; }
        }

        public bool IsReadOnly
        {
            get { return true; }
        }

        public bool Remove(T item)
        {
            return this._list.Remove(item);
        }

        public IEnumerator<T> GetEnumerator()
        {
            return this._list.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this._list.GetEnumerator();
        }
    }
}
